<template>
  <section class="list-wrap">
    <header class="header">
      <div class="header-name">
        <img v-if="data.icon" :src="data.icon" />
        {{ data.name }}
      </div>
      <span class="more" @click="linkHandler(data.moreLink)">更多 ></span>
    </header>
    <article class="list-item-wrap">
      <div class="list-item" v-for="item in data.list" :key="item.link">
        <div class="classImg">
          <img :src="item.classImg" />
        </div>
        <div class="class-name">
          {{ item.className }}
        </div>
        <div class="class-time">{{ item.classTime }}</div>
        <footer class="item-footer">
          <div class="teacher">
            <img class="avatar" :src="item.avatar" v-if="item.avatar" />
            {{ item.teacher }}
          </div>
          <span class="price">{{ item.classPrice }}</span>
        </footer>
      </div>
    </article>
  </section>
</template>
<script>
export default {
  name: "home-list",
  props: {
    data: {
      type: Object,
      default: () => {
        return {
          icon: "",
          moreLink: "",
          name: "",
          list: [],
        };
      },
    },
  },
  methods: {
    linkHandler(path) {
      this.$router.push({
        path,
      });
    },
  },
};
</script>
<style scoped>
.list-wrap {
  overflow: hidden;
}
.header {
  height: 80px;
  display: flex;
  align-items: center;
}
.header-name {
  font-size: 24px;
  font-weight: bold;
  text-align: left;
  color: #323232;
  flex: 1;
  display: flex;
  align-items: center;
}
.header-name img {
  display: block;
  width: 26px;
  height: 26px;
  margin-right: 6px;
}
.more {
  font-size: 16px;
  font-weight: 400;
  text-align: left;
  color: #989898;
  cursor: pointer;
}
.list-item-wrap {
  /* display: flex;
  flex-wrap: wrap; */
  margin-bottom: 20px;
  overflow: hidden;
}
.list-item {
  float: left;
  width: 285px;
  background: #fff;
  margin-right: 20px;
  margin-bottom: 10px;
}
.list-item:nth-child(4n) {
  margin-right: 0;
}
.classImg {
  height: 150px;
  overflow: hidden;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}
.classImg img {
  width: 100%;
  height: 100%;
  display: block;
}
.class-name {
  padding: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 500;
  color: #141414;
}
.item-footer {
  display: flex;
  align-items: center;
  padding: 10px;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
  overflow: hidden;
  justify-content: space-between;
}
.teacher {
  font-size: 14px;
  font-weight: 400;
  color: #646464;
  display: flex;
  align-items: center;
}
.avatar {
  width: 24px;
  height: 24px;
  border-radius: 100%;
  margin-right: 6px;
}
.price {
  font-size: 16px;
  font-weight: 400;
  text-align: left;
  color: #fc212c;
}
.class-time {
  font-size: 14px;
  font-weight: 400;
  color: #969696;
  margin-right: 20px;
  margin-top: 3px;
  padding-left: 10px;
}
</style>
